package com.ctu.study
{
	import flash.display.Sprite;
	
	import flashx.textLayout.compose.*;
	import flashx.textLayout.container.*;
	import flashx.textLayout.conversion.*;
	import flashx.textLayout.edit.*;
	import flashx.textLayout.elements.*;
	import flashx.textLayout.events.*;
	import flashx.textLayout.formats.*;
	import flashx.textLayout.operations.*;
	
	import mx.core.UIComponent;

	public class TestFlow extends UIComponent
	{
		private var _textFlow:TextFlow;
		private var _simpleDataText:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
				"<flow:TextFlow xmlns:flow=\"http://ns.adobe.com/textLayout/2008\" verticalScrollPolicy=\"auto\" horizontalScrollPolicy=\"auto\" fontSize=\"14\" >"+
					"<flow:p>"+
						"<flow:span color=\"#000000\">There are many </flow:span>"+
					"</flow:p>"+
  				"</flow:TextFlow>";
  				
		public function TestFlow()
		{
			super();
			_textFlow = TextFilter.importToFlow(_simpleDataText, TextFilter.TEXT_LAYOUT_FORMAT);
			_textFlow.flowComposer  = new StandardFlowComposer();
			_textFlow.fontFamily = "Trebuchet MS";
			_textFlow.interactionManager = new EditManager(new UndoManager());
			
			var container:Sprite = new Sprite();
			var controller:DisplayObjectContainerController = new DisplayObjectContainerController(container, 400, 300);
			_textFlow.flowComposer.addController(controller);
			_textFlow.flowComposer.updateAllContainers();
			
			var textLine:TextFlowLine = _textFlow.flowComposer.findLineAtPosition(0);
			trace("absStart:"+textLine.absoluteStart);
			addChild(container);
		}
		
	}
}